<template>
	<view class="confirmTransferHouse">
		<view class="select_ku" @click="showkuSelect = true">
			<view>
				<em style="display: inline-block ;color: #f00;">*</em>
				目标仓库：
				<view style="border-radius: 9.52rpx;display: inline-block;border: 1rpx solid #707070FF;">
					<text style="color: #2276BCFF;margin-left: 13.35rpx;">{{kuSelectType_value}}</text>
					<view style="display: inline-block;margin-left: 66.75rpx;margin-right: 13.35rpx;">
						<u-icon name="arrow-down" color="#707070FF" size="35"></u-icon>
					</view>
				</view>
			</view>
			<u-select
			title="选择仓库" 
			:mask-close-able="false" 
			:default-value="[kuSelectValue_default]" 
			v-model="showkuSelect" 
			:list="selectKulist" 
			@confirm="selectKuType">
			</u-select>
		</view>
		<view class="bz">
			<em style="display: inline-block ;color: #f00;">*</em>
			备注用途：<u-input v-model="bz_content" type="textarea" :border="false" :height="96" :auto-height="true" />
		</view>
		<view>
			<view style="padding: 0 32.04rpx 20rpx 32.04rpx">货品名称：</view>
			<scroll-view scroll-y class="content_scroll">
				<yt-card head=" " v-for="(item,index) in selectcarts" :key="index">
					<view class="content">
						<view class="content_img_box">
							<image class="content_img" src="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-baf89db3-4d55-4b1f-a05e-c0a1170f8dce/981a7502-fefb-4ff6-bec6-7513cd717fa7.jpg"></image>
						</view>
						<view class="content_text">
							<view class="content_text_cartName">
								商品名称：<text style="color: #9E2424FF;">{{item.cartName}}</text>
							</view>
							<view class="content_text_type">
								<view class="type_1">
									灶具进风：<text style="color: #9E2424FF;margin-right: 20rpx;">{{item.jf}}</text>
									气源类别：<text style="color: #9E2424FF;">{{item.lb}}</text>
								</view>
								<view class="type_2">
									灶具出风：<text style="color: #9E2424FF;margin-right: 20rpx;">{{item.cf}}</text>
									灶眼数量：<text style="color: #9E2424FF;">{{item.zysl}}</text>
								</view>
							</view>
						</view>
					</view>
				</yt-card>
			</scroll-view>
		</view>
		<view class="subimt_ruku">
			<yt-botton btname="转库申请" @click="subimt_zk"></yt-botton>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import ytCard from '../../comment/yt-card.vue'
	import ytBotton from '../../comment/yt-botton.vue'
	export default {
		data() {
			return {
				showkuSelect:false,
				selectKulist:[ //富安居、万泰隆、快环、澳华、吴圩、荣宝华、迷你厂、京东、总仓库。
					{
						value: '1',
						label: '富安居'
					},
					{
						value: '2',
						label: '万泰隆'
					},
					{
						value: '3',
						label: '快环'
					},
					{
						value: '4',
						label: '澳华'
					},
					{
						value: '5',
						label: '吴圩'
					},
					{
						value: '6',
						label: '荣宝华'
					},
					{
						value: '7',
						label: '迷你厂'
					},
					{
						value: '8',
						label: '京东'
					},
					{
						value: '9',
						label: '总仓库'
					}			
				],
				kuSelectValue_default:'8',
				kuSelectType_value:'总仓库',
				bz_content:'',
				selectcarts:[],
				applicant_id:'',
				applicant:'',
				outhouse:'',
				number:1
				
			};
		},
		onLoad(option) {
			var { applicant_id,applicant,selectCarts,outerhouse_name } = option
			this.selectcarts = JSON.parse(decodeURIComponent(selectCarts))
			this.applicant_id = decodeURIComponent(applicant_id)
			this.applicant = decodeURIComponent(applicant)
			this.outhouse = decodeURIComponent(outerhouse_name)
			this.number = this.selectcarts.length
			console.log(this.outhouse)
		},
		methods:{
			subimt_zk(){
				if(this.bz_content == ""){
					this.$refs.uToast.show({
						title: '必须填写备注！',
						type: 'error',
						position:"top"
					})
				}else if(this.kuSelectType_value == this.outhouse){
					this.$refs.uToast.show({
						title: '目标仓库不可与出库仓库相同！',
						type: 'error',
						position:"top"
					})
				}else{
					var Vue = this;
					uni.showModal({
						title:'提交审批',
						content:'您确定提交该条审批吗？',
						success(res) {
							if(res.confirm){
								uniCloud.callFunction({
									name: 'uni-id-cf_mobile',
									data: {
										action:"outerhouse_sp",
										params:{
											applicant_id_outerhouse:Vue.applicant_id,//审批发起人id"
											applicant_outerhouse:Vue.applicant,//"审批发起人用户名"
											outhouse_outerhouse:Vue.outhouse,//"出货仓库"
											transferhouse_outerhouse:Vue.kuSelectType_value,//"转库目标仓库"
											client_outerhouse:"",//"客户姓名"
											client_phone_outerhouse:"",//"客户电话"
											client_local_outerhouse:"",//"客户详细地址"
											number_outerhouse:Vue.number,//出货货品数量"
											cart_names_outerhouse:Vue.selectcarts,//"多个货品名称"array
											istransfer_outerhouse:true,//"是否转库审批"
											comment_outerhouse:Vue.bz_content//备注
										}
									}
								}).then(({result}) => {
									if(result.code){
										this.$refs.uToast.show({
											title: '出错了！请重新登录。',
											type: 'error',
											position:"top"
										})
										uni.reLaunch({
											url:'../login/login'
										})
										uni.hideLoading()
										return;
									}else{
										uni.redirectTo({
											url:"../houseToHouse/houseToHouse?success=true"
										})
										uni.hideLoading()
									}
									console.log(result)
								}).catch(err => {
									console.log(err)
								})
							}
						}
					})
				}
			},
			selectKuType(e){
				this.kuSelectValue_default = e[0].value - 1
				this.kuSelectType_value = e[0].label
			}
			
		},
		components:{
			ytBotton,
			ytCard
		}
	}
</script>

<style lang="scss">
.confirmTransferHouse{
	position: absolute;
	width: 100%;
	min-height: 1480rpx;
	background-color: #EEEEEEFF;
	.select_ku{
		background-color: #fff;
		padding: 26.7rpx 37.4rpx;
		margin: 37.38rpx 0;
		font-size: 30rpx;
	}
	.bz{
		background-color: #fff;
		padding: 26.7rpx 37.4rpx;
		margin: 37.38rpx 0;
		font-size: 30rpx;
		min-height: 256.32rpx;
	}
	.subimt_ruku{
		margin-top: 77.43rpx;
	}
	.content_scroll{
		display: block;
		height: 30vh;
	}
	.content{
		display: inline-flex;
		.content_img_box{
			.content_img{
				border: 2.67rpx solid #7070703D;
				border-radius: 40.05rpx;
				width: 150rpx;
				height: 150rpx;
				margin-right: 20rpx;
			}
		}
		.content_text{
			font-size: 20rpx;
			.content_text_cartName{
				margin-bottom: 25rpx;
			}
			.content_text_type{
				
				.type_1{
					margin-bottom: 25rpx;
				}
				.type_2{
					margin-bottom: 25rpx;
				}
			}
		}
	}
}
</style>
